home *** CD-ROM | disk | FTP | other *** search
/ L' Effet Pommier 3 / L'Effet Pommier - Volume 03.iso / Education et Sciences / Mathématiques / Matt's_Fract 1.05 / Sources / includes / VideoTools.c < prev    next >
C/C++ Source or Header  |  1995-08-13  |  4KB  |  227 lines

  1. #include "AllTools.h"
  2.  
  3. short    oldMBarHeight;
  4. RgnHandle    mBarRgn;
  5. RgnHandle    tempRgn;
  6. RgnHandle    theGrayRgn;
  7. Boolean        alreadyHidden;
  8.  
  9. void DoFillRect(WindowPtr window, Rect theRect, color theColor, short copyMode, videoInfoPtr theScreen)
  10. {
  11. RGBColor    oldColor;
  12. GrafPtr        savePort;
  13.  
  14. GetPort(&savePort);
  15. SetPort(window);
  16. PenMode(copyMode);
  17. GetForeColor(&oldColor);
  18.  
  19. if ((*theScreen).bitsPerPixel != 1)
  20.             {
  21.                 RGBForeColor(&theColor.fillColor);
  22.                 PaintRect(&theRect);
  23.             }
  24.             else
  25.             {
  26.                 FillRect(&theRect, &theColor.pattColor);
  27.             }
  28.  
  29. RGBForeColor(&oldColor);
  30. SetPort(savePort);
  31. }
  32.  
  33. void DoInvertRect(WindowPtr window, Rect theRect, color theColor)
  34. {
  35. GrafPtr        savePort;
  36.  
  37. GetPort(&savePort);
  38. SetPort(window);
  39.  
  40. InvertRect(&theRect);
  41.  
  42. SetPort(savePort);
  43. }
  44.  
  45. void DoFillRgn(WindowPtr window, RgnHandle theRgn,   color    theColor, short copyMode, videoInfoPtr theScreen)
  46. {
  47. RGBColor    oldColor;
  48. GrafPtr    savePort;
  49.  
  50. GetPort(&savePort);
  51. SetPort(window);
  52. PenMode(copyMode);
  53. GetForeColor(&oldColor);
  54. if ((*theScreen).bitsPerPixel != 1)
  55.             {
  56.             RGBForeColor(&theColor.fillColor);
  57.             PaintRgn(theRgn);
  58.             }
  59.             else
  60.             {
  61.                 FillRgn(theRgn, &theColor.pattColor);
  62.             }
  63. RGBForeColor(&oldColor);
  64. SetPort(savePort);
  65. }
  66.  
  67. void DoDrawRect(WindowPtr window, Rect theRect, color theColor, short copyMode, videoInfoPtr theScreen)
  68. {
  69. Pattern    patt;
  70. DrawInfo    drawInfo;
  71.  
  72. drawInfo = SetDrawInfo(window, theColor, copyMode);
  73.  
  74.                 GetIndPattern(&patt, 0, 1);
  75.                 PenPat(&patt);
  76.                 
  77.     DoMoveTo(window, theRect.left, theRect.top);
  78.     DoLineTo(window, theRect.right, theRect.top, theColor, copyMode, theScreen);
  79.     DoLineTo(window, theRect.right, theRect.bottom, theColor, copyMode, theScreen);
  80.     DoLineTo(window, theRect.left, theRect.bottom, theColor, copyMode, theScreen);
  81.     DoLineTo(window, theRect.left, theRect.top, theColor, copyMode, theScreen);
  82.                 
  83. ReSetDrawInfo(drawInfo);
  84. }
  85.  
  86. DrawInfo SetDrawInfo(WindowPtr window, color theColor, short copyMode)
  87. {
  88. Pattern patt;
  89. DrawInfo    drawInfo;
  90.  
  91. SetPort(window);
  92. GetPort(&drawInfo.savePort);
  93. PenMode(copyMode);
  94. GetForeColor(&drawInfo.oldColor);
  95.  
  96. GetIndPattern(&patt, 0, 1);
  97. PenPat(&patt);
  98.                 
  99. return drawInfo;
  100. }
  101.  
  102. void ReSetDrawInfo(DrawInfo drawInfo)
  103. {
  104. Pattern patt;
  105.  
  106. RGBForeColor(&drawInfo.oldColor);
  107. SetPort(drawInfo.savePort);
  108. GetIndPattern(&patt, 0, 1);
  109. PenPat(&patt);
  110. }
  111.  
  112. void DoMoveTo(WindowPtr window,short x, short y)
  113. {
  114. GrafPtr        savePort;
  115.  
  116. GetPort(&savePort);
  117. SetPort(window);
  118. MoveTo(x,y);
  119. SetPort(savePort);
  120. }
  121.  
  122. void DoLineTo(WindowPtr window,short x, short y, color theColor, short copyMode, videoInfoPtr theScreen)
  123. {
  124. GrafPtr        savePort;
  125. RGBColor    oldColor;
  126. Pattern    patt;
  127.  
  128. SetPort(window);
  129. GetPort(&savePort);
  130. PenMode(copyMode);
  131. GetForeColor(&oldColor);
  132.  
  133. if ((*theScreen).bitsPerPixel != 1)
  134.             {
  135.                 GetIndPattern(&patt, 0, 1);
  136.                 PenPat(&patt);
  137.                 RGBForeColor(&theColor.fillColor);
  138.                 LineTo(x,y);
  139.             }
  140.             else
  141.             {
  142.                 PenPat(&theColor.pattColor);
  143.                 LineTo(x,y);
  144.             }
  145.  
  146. RGBForeColor(&oldColor);
  147. SetPort(savePort);
  148. }
  149.  
  150. void DoLineTo2(short x, short y, color theColor, videoInfoPtr theScreen)
  151. {
  152. if ((*theScreen).bitsPerPixel != 1)
  153.             {
  154.                 RGBForeColor(&theColor.fillColor);
  155.                 LineTo(x,y);
  156.             }
  157.             else
  158.             {
  159.                 PenPat(&theColor.pattColor);
  160.                 LineTo(x,y);
  161.             }
  162. }
  163.  
  164. void MbarInit(void)
  165. {
  166. alreadyHidden = FALSE;
  167. }
  168.  
  169. void HideMenuBar(void)
  170. {
  171.     Rect        mBarRect;
  172. if (alreadyHidden == FALSE) 
  173.     {
  174.     oldMBarHeight = LMGetMBarHeight();
  175.     LMSetMBarHeight(0);            /* make the Menu Bar's height zero */
  176.     SetRect(&mBarRect, qd.screenBits.bounds.left, qd.screenBits.bounds.top,
  177.             qd.screenBits.bounds.right, qd.screenBits.bounds.top + oldMBarHeight);
  178.     mBarRgn = NewRgn();
  179.     tempRgn = NewRgn();
  180.     RectRgn(mBarRgn, &mBarRect);
  181.     theGrayRgn = GetGrayRgn();
  182.     UnionRgn(theGrayRgn, mBarRgn, tempRgn);/* tell the desktop it covers the menu*/
  183.     LMSetGrayRgn(tempRgn);                            /* bar */
  184.     PaintOne(nil, mBarRgn);    /* redraw desktop */
  185.     alreadyHidden = TRUE;
  186.     }
  187. }
  188.  
  189. void ShowMenuBar(void)
  190. {
  191. if (alreadyHidden == TRUE) 
  192.     {
  193.     LMSetMBarHeight(oldMBarHeight);    /* make the menu bar's height normal */
  194.     LMSetGrayRgn(theGrayRgn);
  195.     DrawMenuBar();
  196.     DisposeRgn(tempRgn);
  197.     DisposeRgn(mBarRgn);
  198.     alreadyHidden = FALSE;
  199.     }
  200. }
  201.  
  202. void SquareCorners(void)
  203. {
  204.  
  205. }
  206.  
  207. void RoundCorners(void)
  208. {
  209. }
  210.  
  211. void GammaFadeOut(void)
  212. {
  213. }
  214.  
  215. void GammaFadeIn(void)
  216. {
  217. }
  218.  
  219. void ChangeBitDepth(short bitDepth, Boolean color)
  220. {
  221. GDHandle theScreenHandle;
  222.  
  223. theScreenHandle = GetTheGDevice();
  224. if (color != TRUE)  SetDepth(theScreenHandle,bitDepth,1,0);
  225.             else
  226.                     SetDepth(theScreenHandle,bitDepth,1,1);
  227. }